/*	
*	File: mac-address-type.h
*	Date: 2011/11/25
*	User: Ronmaru
*	Desctiption: type for mac address
*/

#ifndef _MAC_ADDRESS_TYPE_H_
#define _MAC_ADDRESS_TYPE_H_

#include <string>
#include <vector>

using namespace std;

class MacAddress : public vector<char>
{
public:
  MacAddress() { };
  MacAddress(const string &mac_address) {
    int addr_temp[6];
    sscanf(mac_address.c_str(), "%2x:%2x:%2x:%2x:%2x:%2x",
      &addr_temp[0], &addr_temp[1], &addr_temp[2], &addr_temp[3], &addr_temp[4], &addr_temp[5]);
    for (int i = 0; i < 6; ++i)
      push_back(addr_temp[i]);
  }

  friend std::ostream& operator<<(std::ostream& os, const MacAddress& addr) {
    for (int i = 0; i < addr.size(); ++i) {
      os << addr[i];
    }
    return os;
  }
};

#endif //_MAC_ADDRESS_TYPE_H_